using System;
using System.Globalization;
using System.Windows.Data;

namespace WpfApp1.Converters
{
    public class GenderConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int gender)
            {
                return gender switch
                {
                    0 => "女",
                    1 => "男",
                    _ => "未知"
                };
            }
            return "未知";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value?.ToString() switch
            {
                "女" => 0,
                "男" => 1,
                _ => -1
            };
        }
    }
}